/*   1:    */ package tt.dz.web.controller.financial;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.util.LinkedHashMap;
/*   5:    */ import java.util.List;
/*   6:    */ import javax.annotation.Resource;
/*   7:    */ import javax.servlet.http.HttpServletRequest;
/*   8:    */ import javax.servlet.http.HttpServletResponse;
/*   9:    */ import org.springframework.stereotype.Controller;
/*  10:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  11:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  12:    */ import tt.dz.biz.service.batchpay.LiabilitiesService;
import tt.dz.common.DzConstants;
/*  13:    */ import tt.dz.common.DzConstants.bizSysCode;
/*  14:    */ import tt.dz.common.DzConstants.payState;
/*  15:    */ import tt.dz.common.DzConstants.userType;
/*  16:    */ import tt.dz.common.ExcelUtill;
/*  17:    */ import tt.dz.common.LogUtil;
/*  18:    */ import tt.dz.vo.MerchLiabilitiesMonthVO;
/*  19:    */ import tt.dz.vo.OrderServiceVO;
/*  20:    */ import tt.dz.vo.ResponseModle;
/*  21:    */ import tt.dz.vo.TranInfoVO;
/*  22:    */ import tt.dz.web.controller.BaseController;
/*  23:    */ 
/*  24:    */ @Controller
/*  25:    */ public class LiabilitiesController
/*  26:    */   extends BaseController
/*  27:    */ {
/*  28:    */   @Resource(name="liabilitiesService")
/*  29:    */   private LiabilitiesService liabilitiesService;
/*  30:    */   
/*  31:    */   @RequestMapping(value={"/listLiabilities"}, produces={"application/json;charset=UTF-8"})
/*  32:    */   @ResponseBody
/*  33:    */   public String listLiabilities(HttpServletRequest rq)
/*  34:    */   {
/*  35: 43 */     ResponseModle responseModle = null;
/*  36:    */     try
/*  37:    */     {
/*  38: 45 */       String batchMonth = rq.getParameter("batchMonth");
/*  39: 46 */       String receiver = rq.getParameter("merchantCode");
/*  40:    */       
/*  41: 48 */       List<MerchLiabilitiesMonthVO> liabilitiesList = this.liabilitiesService.queryLiabilitiesByMonthAndMerchant(batchMonth, receiver);
/*  42: 49 */       responseModle = new ResponseModle("success", liabilitiesList);
/*  43:    */     }
/*  44:    */     catch (Exception e)
/*  45:    */     {
/*  46: 51 */       LogUtil.error("查询运营商应付款异常", e);
/*  47: 52 */       responseModle = new ResponseModle("error", "查询运营商应付款异常");
/*  48:    */     }
/*  49: 54 */     return JSON.toJSONString(responseModle);
/*  50:    */   }
/*  51:    */   
/*  52:    */   @RequestMapping({"/exportExcelDebtMerchantLiabilities"})
/*  53:    */   @ResponseBody
/*  54:    */   public byte[] exportExcelDebtMerchantLiabilities(HttpServletRequest rq, HttpServletResponse response)
/*  55:    */   {
/*  56: 65 */     byte[] bs = null;
/*  57:    */     try
/*  58:    */     {
/*  59: 67 */       String batchMonth = rq.getParameter("batchMonth");
/*  60: 68 */       String receiver = rq.getParameter("merchantCode");
/*  61:    */       
/*  62: 70 */       List<MerchLiabilitiesMonthVO> liabilitiesList = this.liabilitiesService.queryLiabilitiesByMonthAndMerchant(batchMonth, receiver);
/*  63: 71 */       for (MerchLiabilitiesMonthVO temp : liabilitiesList) {
/*  64: 72 */         temp.setStateDesc(
/*  65: 73 */           DzConstants.payState.getPayState(temp.getState()).getDesc());
/*  66:    */       }
/*  67: 75 */       Object fieldMap = new LinkedHashMap();
/*  68: 76 */       ((LinkedHashMap)fieldMap).put("付款方", "palyerName");
/*  69: 77 */       ((LinkedHashMap)fieldMap).put("收款方", "receiverName");
/*  70: 78 */       ((LinkedHashMap)fieldMap).put("科目", "subjectName");
/*  71: 79 */       ((LinkedHashMap)fieldMap).put("金额(元)", "amount");
/*  72: 80 */       ((LinkedHashMap)fieldMap).put("笔数", "totalCount");
/*  73: 81 */       ((LinkedHashMap)fieldMap).put("月份", "accountingMonth");
/*  74: 82 */       ((LinkedHashMap)fieldMap).put("状态", "stateDesc");
/*  75:    */       
/*  76: 84 */       bs = ExcelUtill.getXLSByteArray("应付款报表", (LinkedHashMap)fieldMap, liabilitiesList);
/*  77:    */       
/*  78: 86 */       response.setHeader("Content-Disposition", "attachment;fileName=demo.csv");
/*  79: 87 */       response.setHeader("Content-Transfer-Encoding", "binary");
/*  80: 88 */       response.setContentType("application/vnd.ms-excel; charset=utf-8");
/*  81:    */     }
/*  82:    */     catch (Exception e)
/*  83:    */     {
/*  84: 90 */       LogUtil.error("导出应付款异常", e);
/*  85:    */     }
/*  86: 92 */     return bs;
/*  87:    */   }
/*  88:    */   
/*  89:    */   @ResponseBody
/*  90:    */   @RequestMapping(value={"/payListLiabilities"}, produces={"application/json;charset=UTF-8"})
/*  91:    */   public String pay(HttpServletRequest request)
/*  92:    */   {
/*  93:104 */     ResponseModle responseModle = null;
/*  94:105 */     MerchLiabilitiesMonthVO merchLiabilitiesMonthVO = (MerchLiabilitiesMonthVO)JSON.parseObject(request.getParameter("liabilities"), MerchLiabilitiesMonthVO.class);
/*  95:    */     try
/*  96:    */     {
/*  97:108 */       LogUtil.debug(merchLiabilitiesMonthVO.toString());
/*  98:109 */       TranInfoVO tranInfo = new TranInfoVO();
/*  99:110 */       tranInfo.setServiceNo(merchLiabilitiesMonthVO.getServiceNo());
/* 100:111 */       tranInfo.setPayStateCode(DzConstants.payState.PAY_SUCCESS.value());
/* 101:112 */       tranInfo.setPayTypeCode(merchLiabilitiesMonthVO.getPayTypeCode());
/* 102:113 */       tranInfo.setChannelCode(merchLiabilitiesMonthVO.getChannelCode());
/* 103:114 */       tranInfo.setPaymentAmount(merchLiabilitiesMonthVO.getAmount());
/* 104:115 */       tranInfo.setAppId(DzConstants.bizSysCode.MAIN_SERVER.value());
/* 105:    */       
/* 106:117 */       tranInfo.setPayer(merchLiabilitiesMonthVO.getMerchantCode());
/* 107:118 */       tranInfo.setPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
/* 108:119 */       tranInfo.setOriginalPayer(merchLiabilitiesMonthVO.getMerchantCode());
/* 109:120 */       tranInfo.setOriginalPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
/* 110:121 */       tranInfo.setReceiver(merchLiabilitiesMonthVO.getMerchantCode1());
/* 111:122 */       tranInfo.setReceiverType(DzConstants.userType.MERCHANT_CUSTOMER.value());
/* 112:    */       
/* 113:124 */       this.liabilitiesService.savePayLiabilities(merchLiabilitiesMonthVO, tranInfo);
/* 114:    */       
/* 115:126 */       responseModle = new ResponseModle("success", null);
/* 116:    */     }
/* 117:    */     catch (Exception e)
/* 118:    */     {
/* 119:128 */       LogUtil.error("运营商应付账款结算异常,参数为：merchLiabilitiesMonthVO=" + merchLiabilitiesMonthVO, e);
/* 120:129 */       responseModle = new ResponseModle("error", "运营商应付账款结算异常");
/* 121:    */     }
/* 122:131 */     return JSON.toJSONString(responseModle);
/* 123:    */   }
/* 124:    */   
/* 125:    */   @RequestMapping(value={"/querySettlementServiceList"}, produces={"application/json;charset=UTF-8"})
/* 126:    */   @ResponseBody
/* 127:    */   public String querySettlementServiceList(HttpServletRequest rq)
/* 128:    */   {
/* 129:141 */     ResponseModle responseModle = null;
/* 130:    */     try
/* 131:    */     {
/* 132:143 */       String subjectNo = rq.getParameter("subSubjectCode");
/* 133:144 */       List<OrderServiceVO> liabilitiesList = this.liabilitiesService.querySettlementServiceList(subjectNo);
/* 134:145 */       responseModle = new ResponseModle("success", liabilitiesList);
/* 135:    */     }
/* 136:    */     catch (Exception e)
/* 137:    */     {
/* 138:147 */       LogUtil.error("查询结算服务异常", e);
/* 139:148 */       responseModle = new ResponseModle("error", "查询结算服务异常");
/* 140:    */     }
/* 141:150 */     return JSON.toJSONString(responseModle);
/* 142:    */   }
/* 143:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.financial.LiabilitiesController
 * JD-Core Version:    0.7.0.1
 */